#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/1/9 0009 13:05
# @Author  : Arliki
# @email   : hkdnxycz@outlook.com
# @File    : error

# ↓↓↓↓↓↓↓↓logging  #保存错误信息到logs.log文件
import logging  # 错误日志
import logging.config
import pdb

logging.config.fileConfig(open("logger.conf", encoding='utf-8'))
logger = logging.getLogger('time_roll')

logging.basicConfig(level=logs.DEBUG,  # 写入报错的最低等级
                    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',  # 写入错误的格式
                    datefmt='%Y%m%d %a %H:%M:%S',  # 写入时间样式
                    filename='logs.log',  # 文件
                    filemode='a+')  # 写入方式
##输出到屏幕的样式和输出等级
# console=logs.StreamHandler()
# console.setLevel(logs.INFO)
# log_format=logs.Formatter('%(name)-12s:%(filename)-8s[line:%(lineno)d] %(funcName)-8s:%(levelname)-8s %(message)s')
# console.setFormatter(log_format)
# logs.getLogger('').addHandler(console)
##使用配置文件 保存到本地并输出显示
logger.critical('测试啊 test')
logger.error('error test')
logger.warning('warning test')
logger.info('info test')
logger.debug('debug test')


# ↑↑↑↑↑↑↑↑logging
def foo(s):
    n = int(s)
    pdb.set_trace()  # 设置断点 p 查看变量值 c继续 导入pdb模块
    # assert n!=0,'n is zero' #屏蔽assert python -0 *.py
    return 10 / n


def bar():
    try:
        foo('0')
    except:
        logging.exception("error")


# bar()
s = '2'
n = int(s)
logging.info('n====%s' % (n))
print(10 / n)
